package br.ufal.tci.nexos.arcolive.beans;

import java.awt.*;
import java.awt.event.*;
import java.beans.Introspector;
import java.io.Serializable;

import javax.swing.*;

/**
 * @author <a href="mailto:felipe@labpesquisas.tci.ufal.br">Felipe Barros Pontes</a>.
 * @author <a href="mailto:leandro@labpesquisas.tci.ufal.br">Leandro Melo de
 *         Sales</a>.
 */
public class Chat extends JPanel implements Serializable {

	/**
	 * 
	 */
	public Chat() {
		initComponents();
	}

	/**
	 * 
	 */
	public void initComponents() {
		textArea = new JTextArea();
		nicknamesList = new JList();
		defaultListNicknames = new DefaultListModel();
		nicknamesScrollPane = new JScrollPane();
		textAreaScrollPane = new JScrollPane();
		textField = new JTextField();
		setLayout(new BorderLayout());
		textAreaScrollPane.setViewportView(textArea);
		nicknamesList.setModel(defaultListNicknames);
		nicknamesScrollPane.setPreferredSize(new Dimension(150, 150));
		nicknamesScrollPane.setViewportView(nicknamesList);
		textField.setText("");
		textField.requestFocus();
		add(textAreaScrollPane, "Center");
		add(nicknamesScrollPane, "After");
		add(textField, "Last");
		nicknamesScrollPane.setCursor(Cursor.getPredefinedCursor(12));
		Font fixedsys = new Font("fixedsys", 1, 12);
		textField.setFont(fixedsys);
		textArea.setFont(fixedsys);
		textArea.setEditable(false);
		textArea.setLineWrap(true);
		textField.requestFocus();
		textField.addKeyListener(new KeyAdapter() {

			public void keyPressed(KeyEvent e) {
				if (e.getKeyCode() == 10) {
					String messageTextField = textField.getText();
					textField.setText("");
				}
				e.getKeyCode();
				e.getKeyCode();
			}

		});
		nicknamesList.addMouseListener(new MouseAdapter() {

			public void mousePressed(MouseEvent mouseevent) {
			}

		});
	}

	private JTextArea textArea;

	private JList nicknamesList;

	private DefaultListModel defaultListNicknames;

	private JScrollPane nicknamesScrollPane;

	private JScrollPane textAreaScrollPane;

	private JTextField textField;

}